export default throttle = (fn, delay = 100) => {
  let timer = null
  let preTime = Date.now().getTime()
  return function () {
    let context = this, args = arguments, nowTime = Date.now().getTime()
    clearTimeout(timer)
    if (nowTime - preTime >= delay) {
      fn.apply(context, args)
      preTime = nowTime
    } else {
      timer = setTimeout(() => {
        fn.apply(context, args)
        timer = null
      }, delay);
    }
  }
}